package model

import (
	"api/helper"
	"time"

	"gorm.io/gorm"
)

type Model struct {
	Id        string `gorm:"size:40;primaryKey;not null"` // ID generate by primitive.NewObjectID().Hex()
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt time.Time
}

func (m *Model) BeforeCreate(tx *gorm.DB) (err error) {
	if m.Id == "" {
		m.Id = helper.GetObjectId()
	}
	return nil
}

type Response struct {
	Code int         `json:"code"`
	Data interface{} `json:"data"`
	Msg  string      `json:"msg"`
}
